/*
 * @Author: namelll 2677065112@qq.com
 * @Date: 2023-06-14 16:00:17
 * @LastEditors: namelll 2677065112@qq.com
 * @LastEditTime: 2023-06-14 16:06:10
 * @FilePath: \vue3-ts-project\src\api\product\index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

import request from "@/utils/request";
//引入类型
import type { TradeMarkResponseData, TradeMark } from './types'
//品牌管理模块接口
enum API {
    //获取品牌列表
    TRADEMARK_URL = "/admin/product/baseTrademark/",
    //添加品牌
    ADDTRADEMARK_URL = '/admin/product/baseTrademark/save',
    //修改品牌
    UPDATETRADEMARK_URL = '/admin/product/baseTrademark/update',
    //删除品牌
    DELETETRADEMARK_URL = '/admin/product/baseTrademark/remove/'
}
//获取品牌列表接口
//page:获取第几页 ---默认第一页
//limit:获取几个已有品牌的数据
export const reqTrademark = (page: number, limit: number) => request.get<any, TradeMarkResponseData>(API.TRADEMARK_URL + `${page}/${limit}`);

//添加|修改品牌接口
export const reqAddOrUpdateTrademark = (data: TradeMark) => {
    //有id就是修改品牌，否则是添加
    if (data.id) {
        return request.put<any, any>(API.UPDATETRADEMARK_URL, data);
    } else {
        //新增品牌 
        return request.post<any, any>(API.ADDTRADEMARK_URL, data);
    }
}

//删除品牌接口
export const reqDeleteTrademark = (id: number) => request.delete<any, any>(API.DELETETRADEMARK_URL + id)